package com.love.marriage.job;

import com.love.marriage.cloud.service.WechatService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * author: majf
 * createDate: 2024/11/7 22:53
 * description: 用户匹配提醒定时
 * version: 1.0.0
 */
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class UserNoticeJob {

    private final WechatService wechatService;

    @Scheduled(cron = "0 0 22 * * ?") // 每天上午9点执行一次
    public void noticeUser() throws WxErrorException {
        log.info("每日更新用户匹配信息，开始====================");
        try {
            wechatService.sentUserPartnerMessageInfo();
        } catch (Exception e) {
            log.error("每日更新用户匹配信息，失败====================:{}", e.getMessage());
        }
        log.info("每日更新用户匹配信息，结束====================");
    }

}
